﻿using Common;
using Common.Dtos;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Sigma.Admin.API.Authoriza;
using Sigma.Admin.API.Services;

namespace Sigma.Admin.API.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class PermissionController : ControllerBase
    {
        private readonly IPermissionService service;

        public PermissionController(IPermissionService service)
        {
            this.service = service;
        }

        [HttpPost]
        //[PermissionAuthorize("Per_Add")]
        [AllowAnonymous]
        public async Task<ApiResponse> AddPermission(PermissionDto dto)
        {
            return await service.AddAsync(dto);
        }

        [HttpGet]
        [PermissionAuthorize("Per_Get")]
        public async Task<ApiResponse<List<PermissionDto>>> GetPermission()
        {
            return await service.GetAllAsync();
        }
    }
}
